
/*
  The contents of this file are subject to the Mozilla Public License Version
  1.1 (the "License"); you may not use this file except in compliance with
  the License. You may obtain a copy of the License at 
  http://www.mozilla.org/MPL/ 
  
  Software distributed under the License is distributed on an "AS IS" basis,
  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  for the specific language governing rights and limitations under the License. 
  
  The Original Code is core2: ECMAScript core objects 2nd gig AS2. 
  
  The Initial Developer of the Original Code is
  Zwetan Kjukov <zwetan@gmail.com>.
  Portions created by the Initial Developer are Copyright (C) 2003-2006
  the Initial Developer. All Rights Reserved.
  
  Contributor(s):
*/

import buRRRn.ASTUce.*;

class Tests.core2.StringTest extends TestCase
    {
    
    function StringTest( name:String )
        {
        super( name );
        }
    
    function testConstructor()
        {
        //STR_000
        }
    
    function testCharAt()
        {
        //STR_001
        }
    
    function testCharCodeAt()
        {
        //STR_002
        }
    
    function testClone()
        {
        var str1, str2, str3, str4;
        
        str1 = new String( "hello world" );
        str2 = "hello world";
        str3 = str1.clone();
        str4 = str2.clone();
        
        assertEquals( str1, str3,                       "STR_003a" );
        assertSame( str1, str3,                         "STR_003b" );
        assertFalse( str2.referenceEquals( str4 ),      "STR_003c" );
        }
    
    function testStaticCompare()
        {
        var str1, str2, str3, str4;
        
        str1 = new String("hello world");
        str2 = "hello world";
        str3 = "hello worl";
        str4 = "HELLO WORLD";
        
        assertEquals( String.compare( str1, null ),  1,       "STR_004a" );
        assertEquals( String.compare( null, str1 ), -1,       "STR_004b" );
        assertEquals( String.compare( str1, str2 ),  0,       "STR_004c" );
        assertEquals( String.compare( str2, str3 ),  1,       "STR_004d" );
        assertEquals( String.compare( str3, str2 ), -1,       "STR_004e" );
        assertEquals( String.compare( null, null ),  0,       "STR_004f" );
        assertEquals( String.compare( str2, str4, true ),  0, "STR_004g" );
        }
    
    function testCompareTo()
        {
        var str1, str2, str3, obj1;
        
        str1 = new String("hello world");
        str2 = "hello world";
        str3 = "hello worl";
        obj1 = {};
        
        assertEquals( str1.compareTo( null ),  1,         "STR_005a" );
        assertEquals( str1.compareTo( str2 ),  0,         "STR_005b" );
        assertEquals( str1.compareTo( str3 ),  1,         "STR_005c" );
        assertEquals( str3.compareTo( str2 ), -1,         "STR_005d" );
        assertEquals( str1.compareTo( obj1 ),  undefined, "STR_005e" );
        }
    
    function testConcat()
        {
        //STR_006
        }
    
    function testCopy()
        {
        var str1, str2, str3, str4;
        
        str1 = new String("hello world");
        str2 = "hello world";
        str3 = str1.copy();
        str4 = str2.copy();
        
        assertEquals( str1, str3,  "STR_007a" );
        assertNotSame( str1, str3, "STR_007b" );
        assertEquals( str2, str4,  "STR_007c" );
        }
    
    function testEquals()
        {
        var str1, str2, str3;
        
        str1 = "hello world";
        str2 = "hello world";
        str3 = "bonjour le monde";
        
        assertTrue( str1.equals( str2 ),   "STR_008a" );
        assertFalse( str1.equals( str3 ),  "STR_008b" );
        assertFalse( str1.equals( null ),  "STR_008c" );
        }
    
    function testEndsWith()
        {
        var str1, str2, str3;
        
        str1 = "hello world";
        str2 = "world";
        str3 = "monde";
        
        assertTrue( str1.endsWith( str2 ),   "STR_009a" );
        assertFalse( str1.endsWith( str3 ),  "STR_009b" );
        assertFalse( str1.endsWith( null ),  "STR_009c" );
        }
    
    function testStaticFormat()
        {
        //STR_010
        }
    
    function testStaticFromCharCode()
        {
        //STR_011
        }
    
    function testIndexOf()
        {
        //STR_012
        }
    
    function testIndexOfAny()
        {
        //STR_013
        }
    
    function testInsert()
        {
        //STR_014
        }
    
    function testLastIndexOf()
        {
        //STR_015
        }
    
    function testLastIndexOfAny()
        {
        //STR_016
        }
    
    function testPadLeft()
        {
        //STR_017
        }
    
    function testPadRight()
        {
        //STR_018
        }
    
    function TestReplace()
        {
        var str1, str2;
        
        str1 = "123abc456";
        str2 = "x";
        
        assertEquals( str1.replace( "abc", "000" ), "123000456", "STR_019a" );
        assertEquals( str1.replace( "abc", "" ),    "123456",    "STR_019b" );
        assertEquals( str2.replace( "", "" ),        str2,       "STR_019c" );
        assertEquals( str2.replace( "x", "a" ),     "a",         "STR_019d" );
        }
    
    function testSlice()
        {
        //STR_020
        }
    
    function testSplit()
        {
        //STR_021
        }
    
    function testStartsWith()
        {
        var str1, str2, str3;
        
        str1 = "hello world";
        str2 = "hello";
        str3 = "monde";
        
        assertTrue( str1.startsWith( str2 ),   "STR_022a" );
        assertFalse( str1.startsWith( str3 ),  "STR_022b" );
        assertFalse( str1.startsWith( null ),  "STR_022c" );
        }
    
    function testSubstr()
        {
        //STR_023
        }
    
    function testSubstring()
        {
        //STR_024
        }
    
    function testToBoolean()
        {
        //STR_025
        }
    
    function testToCharArray()
        {
        //STR_026
        }
    
    function testToLowerCase()
        {
        //STR_027
        }
    
    function testToNumber()
        {
        //STR_028
        }
    
    function testToObject()
        {
        //STR_029
        }
    
    function testToPrimitive()
        {
        //STR_030
        }
    
    function testToSource()
        {
        var str1, str2;
        var src1, src2;
        
        /* attention:
           \v notation is buggy in ActionScript and JScript
           prefere the unicode notation \u000B for vertical tab
        */
        str1 = " h\be\tl\nl\ro w\fo\u000Br\"\'l\\d ";
        src1 = "\" h\\be\\tl\\nl\\ro w\\fo\\vr\\\"\\\'l\\\\d \"";
        /* tonari no totoro ;) */
        str2 = "\u3068\u306A\u308A\u306E\u30C8\u30C8\u30ED";
        src2 = "\"\\u3068\\u306a\\u308a\\u306e\\u30c8\\u30c8\\u30ed\"";
        
        assertEquals( str1.toSource(), src1, "STR_031a" );
        assertEquals( str2.toSource(), src2, "STR_031b" );
        }
    
    function testToUpperCase()
        {
        //STR_032
        }
    
    function testTrim()
        {
        //STR_033
        }
    
    function testTrimEnd()
        {
        //STR_034
        }
    
    function testTrimStart()
        {
        //STR_035
        }
    
    }

